package com.bank.basic.controller;

import com.bank.basic.service.TransferService;
import com.bank.common.commonUtil.AuthContextHolderUtil;
import com.bank.model.vo.transfer.TransferHistoryVo;
import com.bank.model.vo.transfer.TransferVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author Cejay1314
 * @version 1.0
 * @create 2023/2/5 22:52
 */


@RestController
@RequestMapping(value = "/basic/transfer")
public class TransferController {
    @Autowired
    TransferService transferService;

    @GetMapping("/query/list")
    public List<TransferVo> queryListVo(HttpServletRequest httpServletRequest){
        Long userId = AuthContextHolderUtil.getUserId(httpServletRequest);
        return transferService.queryListVo(userId);
    }
    @GetMapping("/history")
    public List<TransferHistoryVo> queryTransferHistoryVo(){
        return transferService.queryTransferHistoryVo();
    }
    @PostMapping("/add")
    public void addTransfer(@RequestBody TransferVo TransferVo, HttpServletRequest httpServletRequest){
        transferService.addTransfer(TransferVo);
    }
    @GetMapping("/del")
    void delTransfer(@RequestParam Long transferId){
        transferService.delTransfer(transferId);
    }
}
